// Tierless
// Copyright © 2010 Alphora
// This file is licensed under a modified BSD-license (see tierless_license.txt).
using System;
using System.Runtime.Serialization;

namespace Tierless.Framework.EntityTypes
{
	/// <summary>
	/// Represents a column definition within an <see cref="EntityOrder"/>.
	/// </summary>
	[DataContract]
	public class EntityOrderColumn : NamedEntityTypeObject
	{
		/// <summary>
		/// Initializes a new instance of the EntityOrderColumn class.
		/// </summary>
		/// <param name="name">The name of the column.</param>
		/// <param name="direction">The direction, ascending or descending, of the order.</param>
		public EntityOrderColumn(string name, OrderDirection direction)
			: base(name)
		{
			Direction = direction;
		}

		/// <summary>
		/// Initializes a new instance of the EntityOrderColumn class.
		/// </summary>
		/// <param name="name">The name of the column.</param>
		public EntityOrderColumn(string name)
			: this(name, OrderDirection.Ascending)
		{}

		/// <summary>
		/// Gets or sets the direction, ascending or descending, of the order.
		/// </summary>
		[DataMember]
		public OrderDirection Direction { get; set; }

		/// <summary>
		/// Returns a string representation of the entity order column.
		/// </summary>
		/// <returns>A string representation of the entity order column.</returns>
		public override string ToString()
		{
			return string.Format("EntityOrderColumn: Name={0}, Direction={1};", Name, Enum.GetName(typeof (OrderDirection), Direction));
		}
	}
}